import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

import '../utils/base_color_utils.dart';

class ShadowView extends StatefulWidget {
  Widget? child;
  double? radius;
  double? elevation;
  Color? shadowColor;
  Color? bgColor;
  BorderRadius? borderRadius;

  /*
  * 水波纹
  * */
  bool inkWell;

  ShadowView({
    Key? key,
    required this.child,
    this.radius = 0,
    this.elevation = 0,
    this.shadowColor = ColorUtils.line,
    this.bgColor,
    this.borderRadius,
    this.inkWell = false,
  }) : super(key: key);

  @override
  ShadowViewState createState() => ShadowViewState();
}

class ShadowViewState extends State<ShadowView> {
  @override
  Widget build(BuildContext context) {
    return (null == widget.elevation || 0 == widget.elevation) &&
            (true != widget.inkWell)
        ? widget.child!
        : Material(
            borderRadius: widget.borderRadius ?? BorderRadius.circular(widget.radius ?? 0),
            elevation: widget.elevation ?? 0,
            shadowColor: widget.shadowColor,
            color: widget.bgColor,
            child: widget.child,
          );
  }
}
